﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp51
{
    class Program
    {

        public class M1
        {
            int x = 22;
            int y = 33;

            public int X { get => x; set => x = value; }
            public int Y { get => y; set => y = value; }
            public virtual int Add()
            {
                return this.X + this.Y;
            }

        }

        public class M2 : M1
        {
            int z = 44;

            public int Z { get => z; set => z = value; }

            public override int Add()
            {
                return base.Add() + this.Z;

            }

        }

        static void Main(string[] args)
        {
            M1 a = new M1();
            M2 b = new M2();
            Console.WriteLine($"X+Y={ a.Add()}");
            Console.WriteLine($"X+Y+Z={ b.Add()}");

            Console.ReadKey();
        }
    }
}